holybible.view.BookListView = holybible.view.ListView.extend({
	ITEM_TEMPLATE: "<li><a href='javascript:;' ahref='/chapters?vcode=${vcode}&bcode=${bcode}' vcode='${vcode}' bcode='${bcode}' title='${name}'>${name}</a></li>",
	name: "bookList",
	
	init: function() {
		this._super();
		this.model = holybible.model.Book.getInstance();
		this.vcode = null;
	},
	show: function(params) {
		var vcode = params.vcode || null;
		if (!vcode) {
			return;
		}

		this._super(params);
				
		if (this.vcode != vcode) {
			this.clearList();
			this.draw(params);
		}
	},
	draw: function(params) {
		console.log("BookListView draw");
		var vcode = params.vcode || null;
		if (!vcode) {
			return;
		}
		
		this._super();
		this.vcode = vcode;
		var list = this.model.getList(vcode) || [];
		for(var i = 0 ; i < list.length ; i++) {
			var item = $(this.makeHtml(this.ITEM_TEMPLATE, {
				vcode: vcode,
				bcode: list[i].bcode,
				name: list[i].name
			}));
			this.addList(item);
		}

	},
	setEvent: function() {
		this.list.click(function(e) {
			if (e.target.tagName == "A") {
				var el = $(e.target);
				var vcode = el.attr("vcode");
				var bcode = el.attr("bcode");
				showChapterList({
					vcode: vcode,
					bcode: bcode
				});
				e.preventDefault();
			}
		});
	}
});
